@use "./_variables" as *;

body #{$contentClass} {
  code {
    color: var(--textLightenColor);
    padding: 0.25rem 0.5rem;
    margin: 0;
    font-size: 0.9rem;
    transition: color 0.5s ease-in-out;

    background-color: rgba(100, 100, 100, 0.08);
    border-radius: 3px;
    .token {
      &.deleted {
        color: #ec5975;
      }
      &.inserted {
        color: var(--accentColor);
      }
    }
  }
}

body #{$contentClass} {
  pre,
  pre[class*="language-"] {
    line-height: 1.4;
    padding: 1.25rem 1.5rem;
    margin: 0.85rem 0;
    background-color: var(--codeBgColor);
    border-radius: 6px;
    overflow: auto;
    code {
      color: var(--codeColor);
      padding: 0;
      background-color: transparent;
      border-radius: 0;
    }
  }
}

div[class*="language-"] {
  position: relative;

  background-color: var(--codeBg);
  border-radius: 6px;
  .highlight-lines {
    user-select: none;
    padding-top: 1.3rem;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    line-height: 1.4;
    .highlighted {
      background-color: rgba(0, 0, 0, 30%);
    }
  }
  pre,
  pre[class*="language-"] {
    background: transparent;
    position: relative !important;
    z-index: 1;
  }
  &::before {
    position: absolute;
    z-index: 3;
    top: 0.8rem;
    right: 1rem;
    font-size: 0.8rem;
    color: rgba(150, 150, 150, 0.7);
  }
  &:not(.line-numbers-mode) {
    .line-numbers-wrapper {
      display: none;
    }
  }
  &.line-numbers-mode {
    .highlight-lines .highlighted {
      position: relative;
      &:before {
        content: " ";
        position: absolute;
        z-index: 3;
        left: 0;
        top: 0;
        display: block;
        width: $lineNumbersWrapperWidth;
        height: 100%;
        background-color: rgba(0, 0, 0, 30%);
      }
    }
    pre {
      padding-left: $lineNumbersWrapperWidth + 1rem;
      vertical-align: middle;
    }
    .line-numbers {
      position: absolute;
      top: 0;
      width: $lineNumbersWrapperWidth;
      text-align: center;

      color: rgba(127, 127, 127, 0.5);
      padding: 1.25rem 0;
      line-height: 1.4;
      br {
        user-select: none;
      }
      .line-number {
        position: relative;
        z-index: 4;
        user-select: none;
        font-size: 0.85rem;
      }
    }
    &::after {
      content: "";
      position: absolute;
      z-index: 2;
      top: 0;
      left: 0;
      width: $lineNumbersWrapperWidth;
      height: 100%;
      border-radius: 6px 0 0 6px;

      border-right: 1px solid var(--borderColor);
      background-color: var(--codeBg);
    }
  }
}

@each $lang in $codeLang {
  div[class*="language-"].ext-#{$lang}:before {
    content: "" + $lang;
  }
}
